<template>
  <div>
    <el-dialog
      :title="isEdit ? '修改' : title"
      :visible.sync="dialogVisible"
      width="400px"
    >
      <el-form ref="form" :model="form" label-width="100px">
        <!-- <el-form-item label="规则类型">
          <el-select v-model="form.ruleSettingsType" placeholder="请选择">
            <el-option
              v-for="item in dict.RECORDS_DETAIL"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item> -->
        <el-form-item label="积分">
          <el-input v-model="form.ruleSettings"></el-input>
        </el-form-item>
        <el-form-item label="签到日期">
          <el-date-picker
            v-model="form.ruleSettingsDate"
            type="date"
            placeholder="选择签到日期"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submitHandle">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import pointsRule from "@/api/pointsRule/signIn";
export default {
  name: "TrainingDialog",
  components: {},
  props: {
    title: {
      type: String,
      default: "新增"
    }
  },
  dicts: ["RECORDS_DETAIL"],
  data() {
    return {
      dialogVisible: false,
      isEdit: false, //是否编辑
      form: {
        id: "",
        ruleSettings: "",
        ruleSettingsType: "",
        ruleSettingsDate: ""
      }
    };
  },
  computed: {},

  methods: {
    submitHandle() {
      if (this.isEdit) {
        //修改
        pointsRule
          .signInEdit(this.form)
          .then(res => {
            this.dialogVisible = false;
            this.$notify({ message: "操作成功", type: "success" });
            this.$emit("submitSuccess");
          })
          .catch(() => {});
      } else {
        pointsRule
          .signInAdd(this.form)
          .then(res => {
            this.dialogVisible = false;
            this.$notify({ message: "操作成功", type: "success" });
            this.$emit("submitSuccess");
          })
          .catch(() => {});
      }
    }
  }
};
</script>

<style lang="scss"></style>
